package org.yibinxueyuan.drawcard.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.yibinxueyuan.drawcard.entity.Cardinfo;
import org.yibinxueyuan.drawcard.service.CardInfoService;

import javax.annotation.Resource;
import java.util.List;

/**
 *  这个类已经没有存在的必要了ajax已经取代
 * 主页的控制
 */
@Controller
public class IndexController {
    @Resource(name = "CardinfoServiceImpl")
    private CardInfoService cardInfoService;


    /**
     * 抽卡(单抽,10连)
     */
    @RequestMapping("/index/getcards")
    public String getCards(Integer number,Model model){
        //随机获取number张卡片
        List<Cardinfo> cardinfos = cardInfoService.getCardsByRandom(number);
        model.addAttribute("message",number+"连");
        model.addAttribute("cardinfos",cardinfos);
        return "index";
    }
}
